function h=paintgroups( groups, img, factor );
% h=paintgroups( groups, imag, factor=1 ) paints groups calcuted by findgroups, o
% image img. groups are stretched by factor
% returns handle to image

h = image( img );
hold on;

if exist('factor') ~= 1
	factor = 1;
end

for i = 1:size(groups,1)
	group = groups(i);
	% paint boundaries
	xs = [ group.minX-1	group.maxX+1	group.maxX+1 group.minX-1	group.minX-1 ];
	ys = [ group.minY-1	group.minY-1	group.maxY+1 group.maxY+1	group.minY-1 ];
	
	plot( xs* factor, ys* factor );
	
	% paint center
	plot( group.centerX * factor, group.centerY * factor, '+g' );
end

hold off;